/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.uoc.tdp.pac4.only5.gui.client.model;

import edu.uoc.tdp.pac4.only5.vo.ResourceBookingVO;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Gerard
 */
public class ResourceBookingVOTableModel extends AbstractTableModel {
    
    private List<ResourceBookingVO> elements;
    
    private String[] columns;
    
    private boolean allDay;

    public ResourceBookingVOTableModel(List<ResourceBookingVO> elements, String[] columns, boolean allDay) {
        this.elements = elements;
        this.columns = columns;
        this.allDay = allDay;
    }

    @Override
    public int getRowCount() {
        int i = 0;
        if(elements != null && elements.size() > 0){
            i = elements.size();
        }
        return i;
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }

    @Override
    public Object getValueAt(int row, int column) {
       if(elements != null && elements.size() > 0){
            switch(column){
               case 0: return elements.get(row).getResource().getResource_desc();
               case 1: return elements.get(row).getResource().getPrice_day();
               case 2: return elements.get(row).getResource().getPrice_hour();
               case 3: return elements.get(row).getBooked();
               case 4: return elements.get(row).calculatePriceBooked(allDay);
            }
        }
        return null;
    }
    
}
